<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    textarea{width:300px;height: 500px;}
  </style>
</head>
<body>
  <textarea class="txt1"></textarea>
  <input type="button" value="转换" class="btn">
  <textarea class="txt2"></textarea>
</body>
<script>

  const txt1 = document.querySelector(".txt1")
  const txt2 = document.querySelector(".txt2")
  const btn = document.querySelector(".btn")

  // 正则的贪婪特性：尽可能的多匹配

  btn.onclick = function(){
    const str = txt1.value;

    // html标签的替换正则
    const reg = /<[^>]+>/g;

    txt2.value = str.replace(reg, "");
  }
  
</script>
</html>